//: C13:Stack4.cpp {O}
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// New version of Stack
#include "Stack4.h"

void* Stack::pop()
{
    if (head == 0) return 0;
    void* result = head->data;
    Link* oldHead = head;
    head = head->next;
    delete oldHead;
    return result;
}

Stack::~Stack()
{
    Link* cursor = head;
    while (head) {
        cursor = cursor->next;
        delete head;
        head = cursor;
    }
} ///:~
